var everydaylist=[];
// pages/userprotocol/userprotocol.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    changeview:true,
    everydaylist:[],//按天排序的时间戳
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var datalist=wx.getStorageSync('datalist');
    this.sortdataList(datalist);
     var everydaylist=this.data.everydaylist;
     console.log(datalist)
  },

 //排序时间戳数据
 sortdataList:function(datalist){
   var that=this;
   var daylist=[];
   var daylist1=[];
  var temp=datalist;
  var temp1=datalist;
  // var templist=datalist.map(function(item,index,datalist){
     loop_1:for(var item=0;item<datalist.length;item++){
    //startTime= new Date(startTime).format("yyyy-MM-dd hh:mm:ss");
  //endTime=new Date(endTime).format("yyyy-MM-dd hh:mm:ss");
  var endtime=new Date(datalist[item].endTime).format("yyyy-MM-dd hh:mm:ss");
    for(var i=0;i<temp.length;i++){
      if(new Date(temp[i].endTime).getDate()===new Date(datalist[item].endTime).getDate()){
        temp[i].endTime=new Date(temp[i].endTime).format("yyyy-MM-dd hh:mm:ss");
        temp[i].startTime=new Date(temp[i].startTime).format("yyyy-MM-dd hh:mm:ss");
        temp[i].day=new Date(temp[i].endTime).format("yyyy-MM-dd")
        // var  arr= temp[i].time.split(":")//持续时间
        // var time=parseInt(arr[0])*3600+parseInt(arr[1])*60+parseInt(arr[2]) 
        // var time=temp[i].time; 
        //  if(typeof(temp[i].time)=='string'){
        //   console.log(typeof(temp[i].time))
        //   time=parseInt(temp[i].time);
        //   if(time<=60){
        //     time=time+"s"
        //   }else{
        //     time=time/60+"min"
        //   }
        //  }
        //  temp[i].time=time;
        console.log(daylist)
        daylist.push(temp[i]);
        
        //temp1.splice(i,1);
        if(i==temp.length-1){
          console.log(i);
           break loop_1; 
        }
      }else{
        // var time=temp[i].time; 
        // if(typeof(temp[i].time)=='string'){
        //  console.log(typeof(temp[i].time))
        //  time=parseInt(temp[i].time);
        //  if(time<=60){
        //    time=time+"s"
        //  }else{
        //    time=time/60+"min"
        //  }
        // }
        // temp[i].time=time;
        daylist1.push(temp[i]);
        if(i==temp.length-1){
          console.log(i);
          break loop_1; 
        }
      }
    }
    
  };
    that.data.everydaylist.push(daylist);
    that.setData({
      everydaylist:that.data.everydaylist
    })
  if(daylist1.length!=0){
    that.sortdataLdaylist1ist(daylist1);
  }
 },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var datalist=wx.getStorageSync('datalist');
    //this.sortdataList(datalist);
    // this.setData({
    //  changeview1:changeview1,
    // })
  },



  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },





  /**
   * 用户点击右上角分享
   */
  changeviewtext:function(){
    var view=this.data.changeview;
    var that=this;
      if(view){
          this.setData({
            changeview:false,
          })
      }else{
        this.setData({
          changeview:true,
        })
       
      }
   
  },
})